package com.relytosoft.mizar.media.display.services.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.relytosoft.dubhe.common.core.object.ResponseResult;
import com.relytosoft.dubhe.common.log.annotation.OpLog;
import com.relytosoft.dubhe.common.log.enums.OpTypeEnum;
import com.relytosoft.mizar.media.display.api.entity.PtzControl;
import com.relytosoft.mizar.media.display.services.service.PtzControlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 云台操作控制器
 *
 * @author hj
 * @version 1.0
 * @date 2022/4/7 14:07
 * @ClassName PtzControlController
 */
@Validated
@RestController
@RequestMapping("display/ptz")
@Api(tags = "云台控制")
public class PtzControlController {
    @Resource
    private PtzControlService ptzControlService;

    @PostMapping("/control")
    @ApiOperation("云台控制")
    @SaCheckPermission("display:ptz:control")
    @OpLog(msg = "云台控制",opType = OpTypeEnum.OTHER)
   public ResponseResult<Void> control(@RequestBody @Valid PtzControl dto) {
        boolean ptz = ptzControlService.controlPtz(dto);
        if (ptz ){
            return ResponseResult.ok();
        }
        return ResponseResult.fail();
    }

}
